<template>
	<view>
		<input type='password' class="inputcss" v-model="password" placeholder="请输入新的密码" />
		<input type='password' class="inputcss" v-model="rePassword" placeholder="重复新的密码" />
		<button class="buttoncss" @tap="handleSubmit">提交</button>
	</view>
</template>

<script>
	import api from "@/common/api.js";
	export default {
		data() {
			return {
				phone: '',
				password: '',
				rePassword: ''
			};
		},
		methods: {
			handleSubmit() {
				console.log(this.password, this.rePassword)
				if (this.password != '') {
					if (this.password !== this.rePassword) {
						uni.showToast({
							title: '两次输入的密码不一致',
							icon: 'none',
							duration: 2000
						})
					} else {
						api.look({
							api: 'updatec',
							call: this.phone,
							table: 1,
							password: this.password
						}).then(res => {
							if (res.code == 200) {
								uni.showToast({
									title: '修改成功',
									icon: 'success',
									duration: 2000,
									success: () => {
										setTimeout(() => {
											uni.navigateTo({
												url: '../../login/login'
											})
										}, 2000)
									}
								})
							}
						}).catch(err => {
							console.log(err)
						})
					}
				} else {
					uni.showToast({
						title: '请输入密码',
						icon: 'none',
						duration: 2000
					})
				}
			}
		},
		onShareAppMessage(options) {
			let shareObj = {
				success: (res) => {
					if (res.errMsg == 'shareAppMessage:ok') {
						uni.showToast({
							title: '分享成功',
							icon: 'success',
							duration: 1500
						})
					}
				},
				fail: () => {
					if (res.errMsg == 'shareAppMessage:fail cancel') {
						uni.showToast({
							title: '取消分享',
							icon: 'none',
							duration: 2000
						})
					} else if (res.errMsg == 'shareAppMessage:fail') {
						// 转发失败，其中 detail message 为详细失败信息
					}
				},
				complete: () => {
					// 转发结束之后的回调（转发成不成功都会执行）
				}
			}
		},
		onLoad(options) {
			this.phone = options.phone
		}
	}
</script>

<style lang="scss">
	.inputcss {
		width: 690rpx;
		height: 100rpx;
		line-height: 100rpx;
		padding-left: 20rpx;
		box-sizing: border-box;
		margin: 40rpx auto 0;
		border-bottom: 1rpx solid #999;
	}

	.buttoncss {
		width: 690rpx;
		height: 100rpx;
		line-height: 100rpx;
		color: #fff;
		font-size: 40rpx;
		text-align: center;
		border-radius: 50rpx;
		background-color: #209FFC;
		margin: 100rpx auto 0;
	}

	.reback {
		width: 151rpx;
		height: 32rpx;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 500;
		text-decoration: underline;
		color: #209FFC;
		margin: 35rpx auto 0;
	}
</style>
